<!--
 * @Author: 生俊甫 1758142861@qq.com
 * @Date: 2024-05-30 14:49:57
 * @LastEditors: 生俊甫 1758142861@qq.com
 * @LastEditTime: 2024-06-17 22:36:42
 * @FilePath: \html5-main\html5-main\html\Index.html
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>南宁理工学院</title>
    <link rel="stylesheet" href="../css/Index.css" type="text/css">
    <link rel="stylesheet" href="../css/photoC.css" type="text/css">
</head>

<body>
    <div id="top">
        <img src="../image/Logo.png" class="img1">
        <div id="top-right">
            <input type="text" name="search" id="search-input" placeholder="请输入关键字">
            <div id="search">搜索</div>
        </div>

        <p id="searchButton"></p>

        <div class="center">
            <span style="color: blue;font-size: 80px">南</span>
            <span style="color: red;font-size: 80px">宁</span>
            <span style="color: orange;font-size: 80px">理</span>
            <span style="color: blue;font-size: 80px">工</span>
            <span style="color: #00aa00;font-size: 80px">学</span>
            <span style="color: orange;font-size: 80px">院</span>
        </div>
        <div id="top-gov">
            <a href="https://www.bwgl.cn//">南宁理工学院</a>
            &nbsp;&nbsp;&nbsp;&nbsp;
            <a href="http://www.weather.com.cn/weather/101300501.shtml">桂林天气</a>; 
        </div>
    </div>
    <hr style="height:10px;border:none;border-top:10px groove rgb(14,
            143, 194);" />
    <div id="top2">
        <div id="nav">
            <ul>
                <li><a href="./Index_hall.html">首页</a></li>
                <li><a href="../html/History.html">学校简介</a></li>
                <li><a href="../html/daily.html">校园日常</a></li>
                <li><a href="../html/Foods.html">校园美食</a></li>
                <li><a href="../html/Views.html">校园风景</a></li>
                <li><a href="../html/Traffic.html">位置信息</a></li>
                <li><a href="../html/News.html">新闻速递</a></li>
                <li><a href="../html/honor.html">学校荣誉</a></li>
                <li><a href="../html/introduction.html">学院简介</a></li>
            </ul>
        </div>
    </div>
    <h1>个人中心</h1>
    <h3><div id="user_id">学生ID</div></h3>
    <h3><div id="user">用户</div></h3>
    <div id="bottom">
        Copyright © 2021级通信工程一班 生俊甫 21090126. All rights reserved.&nbsp;&nbsp;
        <a href="../html/contactUs.html">联系我们</a>
        <a href="#top">回到顶部</a>
    </div>
</body>
<script src="./js/jquery.min.js"></script>
<script>
    var ws_url = "ws://" + location.host + "/hall";
    var ws_hdl = null;
    window.onbeforeunload = function () {
        ws_hdl.close();
    }
    function get_user_info() {
        $.ajax({
            url: "/info",
            type: "get",
            success: function (res) {
                // var info_html = "<p>" + "用户:" + res.username + "</p>";
                var info_html = "学生ID:" + res.id;
                var screen_div = document.getElementById("user_id")
                screen_div.innerHTML = info_html;
                var info_html1 = "学生姓名:" + res.username;
                var screen_div1 = document.getElementById("user")
                screen_div1.innerHTML = info_html1;
                ws_hdl = new WebSocket(ws_url);
                ws_hdl.onopen = ws_onopen;
                ws_hdl.onclose = ws_onclose;
                ws_hdl.onerror = ws_onerror;
                ws_hdl.onmessage = ws_onmessage;
            },
            error: function (xhr) {
                alert(JSON.stringify(xhr));
                location.replace("/login.html");
            }
        })
    }
    function ws_onopen() {
        console.log("websocket onopen");
    }
    function ws_onclose() {
        console.log("websocket onopen");
    }
    function ws_onerror() {
        console.log("websocket onopen");
    }
    function ws_onmessage(evt) {
        var rsp_json = JSON.parse(evt.data);
        if (rsp_json.result == false) {
            alert(evt.data);
            location.replace("/login.html");
            return;
        }
        if (rsp_json["optype"] == "hall_ready") { 
            alert("以为您跳转到个人中心！");
        } else {
            alert(evt.data);
            location.replace("/login.html");
            return;
        }
    }
    get_user_info();
</script>

</html>